package Services;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.CallableStatement;

public class AddFilmService {
	Connection con;
	CallableStatement stmt;
	ResultSet rs;

	public int addFilm(String filmName, String filmDesc, String filmGenre,
			int memberID) {
		DBConnection connection = new DBConnection();
		int returncode = 0;
		try {
			con = connection.getConnection();
		} catch (Exception e) {
			e.printStackTrace();
		}

		try {
			stmt = con.prepareCall("{call AddFilm(?,?,?,?)}");
			stmt.setString(1, filmName);
			stmt.setString(2, filmDesc);
			stmt.setString(3, filmGenre);
			stmt.setString(4, Integer.toString(memberID));
			rs = stmt.executeQuery();
			while (rs.next()) {
				returncode = rs.getInt("returncode");
			}
		} catch (Exception e) {
			e.printStackTrace();
		}

		return returncode;
	}

}
